package com.hanserwei.consumer;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class SpringRabbitListener {


    // DIRECT 模式

    @RabbitListener(queues = "direct.queue1")
    @SneakyThrows
    public void listenDirectQueue1(String message) {
        log.info("消费者1监听direct.queue1成功，消息内容是：{}", message);
    }

    @RabbitListener(queues = "direct.queue2")
    @SneakyThrows
    public void listenDirectQueue2(String message) {
        log.info("消费者2监听direct.queue2成功，消息内容是：{}", message);
    }

    // TOPIC 模式

    @RabbitListener(queues = "topic.queue1")
    @SneakyThrows
    public void listenTopicQueue1(String message) {
        log.info("消费者1监听topic.queue1成功，消息内容是：{}", message);
    }

    @RabbitListener(queues = "topic.queue2")
    @SneakyThrows
    public void listenTopicQueue2(String message) {
        log.info("消费者2监听topic.queue2成功，消息内容是：{}", message);
    }

    @RabbitListener(queues = "topic.queue3")
    @SneakyThrows
    public void listenTopicQueue3(String message) {
        log.info("消费者3监听topic.queue3成功，消息内容是：{}", message);
    }

    @RabbitListener(queues = "ttl.dead.queue")
    @SneakyThrows
    public void listenTTLQueue(String message) {
        log.info("消费者监听ttl.dead.queue成功，消息内容是：{}", message);
    }
}
